package com.zbkj.service.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zbkj.common.model.UserAiVideoUrl;
import com.zbkj.common.model.user.User;
import com.zbkj.common.page.CommonPage;
import com.zbkj.common.request.PageParamRequest;
import com.zbkj.service.dao.UserAiVideoUrlDao;
import com.zbkj.service.service.UserAiVideoUrlService;
import com.zbkj.service.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author keNan
 * @description UserAiVideoUrlServiceImpl 接口实现
 * @date 2025-05-09
 */
@Service
public class UserAiVideoUrlServiceImpl extends ServiceImpl<UserAiVideoUrlDao, UserAiVideoUrl> implements UserAiVideoUrlService {

    @Autowired
    private UserService userService;


    @Override
    public PageInfo<UserAiVideoUrl> getVideoUrlList(PageParamRequest pageParamRequest) {
        User user = userService.getInfo();
        Page<Object> page = PageHelper.startPage(pageParamRequest.getPage(), pageParamRequest.getLimit());
        LambdaQueryWrapper<UserAiVideoUrl> lqw = new LambdaQueryWrapper();
        lqw.eq(UserAiVideoUrl::getUid, user.getId());
        lqw.orderByDesc(UserAiVideoUrl::getId);
        List<UserAiVideoUrl> list = list(lqw);
        return CommonPage.copyPageInfo(page, list);
    }
}

